#include <ani.h>
#include <array>
#include <chrono>
#include <iostream>
#include <thread>

#include "ani_helpers_build_scripts.h"

static ani_int Sum([[maybe_unused]] ani_env *env, [[maybe_unused]] ani_object object, ani_int a, ani_int b) {
  return a + b;
}

ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) {
  ani_env *env;
  CHECK_ANI_FATAL(vm->GetEnv(ANI_VERSION_1, &env));

  constexpr const char *className = "BootNativeAPI.BootNativeAPI";
  ani_class cls;
  CHECK_ANI_FATAL(env->FindClass(className, &cls));

  std::array methods = {
      ani_native_function{"doSum", "ii:i", reinterpret_cast<void *>(Sum)},
  };

  CHECK_ANI_FATAL(env->Class_BindNativeMethods(cls, methods.data(), methods.size()));

  *result = ANI_VERSION_1;
  return ANI_OK;
}
